
/**
  ******************************************************************************
  * Copyright 2021 The Microbee Authors. All Rights Reserved.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * 
  * http://www.apache.org/licenses/LICENSE-2.0
  * 
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  * 
  * @file       rc_mapper.c
  * @author     baiyang
  * @date       2022-11-2
  ******************************************************************************
  */

/*----------------------------------include-----------------------------------*/
#include "rc_mapper.h"

#include <parameter/param.h>
/*-----------------------------------macro------------------------------------*/

/*----------------------------------typedef-----------------------------------*/

/*---------------------------------prototype----------------------------------*/

/*----------------------------------variable----------------------------------*/
static param_t var_info[] = {
    // @Param: ROLL
    // @DisplayName: Roll channel
    // @Description: Roll channel number. This is useful when you have a RC transmitter that can't change the channel order easily. Roll is normally on channel 1, but you can move it to any channel with this parameter.  Reboot is required for changes to take effect.
    // @Range: 1 16
    // @Increment: 1
    // @User: Advanced
    // @RebootRequired: True
    PARAM_DEFINE_INT8(RCMAP_ROLL, 1),

    // @Param: PITCH
    // @DisplayName: Pitch channel
    // @Description: Pitch channel number. This is useful when you have a RC transmitter that can't change the channel order easily. Pitch is normally on channel 2, but you can move it to any channel with this parameter.  Reboot is required for changes to take effect.
    // @Range: 1 16
    // @Increment: 1
    // @User: Advanced
    // @RebootRequired: True
    PARAM_DEFINE_INT8(RCMAP_PITCH, 2),

    // @Param: THROTTLE
    // @DisplayName: Throttle channel
    // @Description: Throttle channel number. This is useful when you have a RC transmitter that can't change the channel order easily. Throttle is normally on channel 3, but you can move it to any channel with this parameter. Reboot is required for changes to take effect.
    // @Range: 1 16
    // @Increment: 1
    // @User: Advanced
    // @RebootRequired: True
    PARAM_DEFINE_INT8(RCMAP_THROTTLE, 3),

    // @Param: YAW
    // @DisplayName: Yaw channel
    // @Description: Yaw channel number. This is useful when you have a RC transmitter that can't change the channel order easily. Yaw (also known as rudder) is normally on channel 4, but you can move it to any channel with this parameter.  Reboot is required for changes to take effect.
    // @Range: 1 16
    // @Increment: 1
    // @User: Advanced
    // @RebootRequired: True
    PARAM_DEFINE_INT8(RCMAP_YAW, 4),

    // @Param{Sub}: FORWARD
    // @DisplayName: Forward channel
    // @Description: Forward channel number. This is useful when you have a RC transmitter that can't change the channel order easily. Forward is normally on channel 5, but you can move it to any channel with this parameter. Reboot is required for changes to take effect.
    // @Range: 1 16
    // @Increment: 1
    // @User: Advanced
    // @RebootRequired: True
    PARAM_DEFINE_INT8(RCMAP_FORWARD, 6),

    // @Param{Sub}: LATERAL
    // @DisplayName: Lateral channel
    // @Description: Lateral channel number. This is useful when you have a RC transmitter that can't change the channel order easily. Lateral is normally on channel 6, but you can move it to any channel with this parameter. Reboot is required for changes to take effect.
    // @Range: 1 16
    // @Increment: 1
    // @User: Advanced
    // @RebootRequired: True
    PARAM_DEFINE_INT8(RCMAP_LATERAL, 7),
};
PARAM_GROUP_DEFINE(RCMAP, var_info);

static struct rc_mapper rcmapper = {.ch_roll     = 1,
                                    .ch_pitch    = 2,
                                    .ch_throttle = 3,
                                    .ch_yaw      = 4,
                                    .ch_forward  = 6,
                                    .ch_lateral  = 7};
/*-------------------------------------os-------------------------------------*/

/*----------------------------------function----------------------------------*/
rc_mapper_t rc_mapper_get_singleton()
{
    return &rcmapper;
}

void rc_mapper_init()
{
    param_link_variable(PARAM_ID(RCMAP, RCMAP_ROLL), &rcmapper.ch_roll);
    param_link_variable(PARAM_ID(RCMAP, RCMAP_PITCH), &rcmapper.ch_pitch);
    param_link_variable(PARAM_ID(RCMAP, RCMAP_THROTTLE), &rcmapper.ch_throttle);
    param_link_variable(PARAM_ID(RCMAP, RCMAP_YAW), &rcmapper.ch_yaw);
    param_link_variable(PARAM_ID(RCMAP, RCMAP_FORWARD), &rcmapper.ch_forward);
    param_link_variable(PARAM_ID(RCMAP, RCMAP_LATERAL), &rcmapper.ch_lateral);
}
/*------------------------------------test------------------------------------*/


